package com.salim.leetcode.$58;

public class LengthofLastWord {
    public int lengthOfLastWord(String s) {
        boolean start = false;
        int length = 0;
        for(int i=0;i<s.length();i++){
            if(start == false && s.charAt(i)!=' '){
                start = true;
                length = 0;
                length++;
            } else if(s.charAt(i)!=' '){
                length++;
            }else if(s.charAt(i) == ' '){
                start = false;
            }
        }
        return length;
    }
}
